// pages/personal/personal.js


import { getPhone } from '../../service/personal.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isHidden:true,
    phone:'',
    myorder: [
      { image: "../image/p3.png", text: "我的订单" },
      { image: "../image/p4.png", text: "联系客服" }],
    myorder1: [
      { image: "../image/p5.png", text: "技术支持" }]
  }, 
  onLoad(){
    if (wx.getStorageSync('phone')) {
      this.setData({ phone: wx.getStorageSync('phone')})
    }
  },
  jump(type) {
    let path = '';
    switch (Number(type.currentTarget.dataset.type)) {
      case 0:
        path = '../order/order';
        break;
      case 1:
        this._getPhone()
        break;
      default:
      break;
    }
    if (path) {
      wx.navigateTo({url: path})
    }
  },
  show() {
    this.setData({
      isHidden: !this.data.isHidden//显示模态框
    })
  },
  _getPhone(){
    if (!this.data.phone) {
      getPhone().then(res => {
        console.log(res)
        if (res.code == 200) {
          this.setData({ phone: res.data.phone })
          wx.setStorageSync('phone', res.data.phone)
          this.show()
        }
      })
    } else {
      this.show()
    }
  }
  })
  

